package com.buba.system.controller;

import com.buba.system.pojo.SystemMenu;
import com.buba.system.service.MenuService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("MenuController")
public class MenuController {
    @Autowired
    @Qualifier("MenuServiceImpl")
    private MenuService menuService;

    @RequiresRoles({"超级管理员"})
    @RequestMapping("selMenu")
    public Map<String,Object> selMenu(){
        Map<String,Object> map=new HashMap<>();
        //获取父级菜单信息
        List<SystemMenu> menuList=menuService.selMenu();
        //根据父级id获取子级菜单
        for (SystemMenu menu:menuList) {
            List<SystemMenu> childList=menuService.selMenuById(menu.getMenu_ID());
            menu.setChildList(childList);
        }
        System.out.println(menuList);
        map.put("menuList",menuList);
      return map;
    };
}
